Original address: http://www.symphonious.net/2011/07/11/lmax-disruptor-high-performance-low-latency-and-simple-too/The LMAX disruptor is an ultra-high performance, low-latency message exchange between threads. It's a bit like a queue on steroids (but quite a lot of steroids) and are one of the key innovations used to make the LMAX Exchange run so fast. There is a
Problem Description: X[i], a sequence of successive sequences called X[i] from any number x[a] to X[b] (a X[i] The sequence and of the subsequence of the subsequence called X[i]. Now known sequence x[i], ask some questions about the maximum sequence and answer. One, the sub-sequence of the most large "Method One" Simple search, using s[i]=s[0]+...+s[i] Perform an O (n^2) lookup and compare S[i]-s[j] (i>j) The maximum value, which is the answer Code Slightly "Scope of Application" Need to visuall
Uestc_1546
This question can be used to judge the sequence of legal parentheses and regard '(' as 1, ')' As-1, then scan a sequence from left to right and accumulate the scanned values. In this process, if the sum of these values is not less than 0 at any time, and the sum of these values is 0 at the end, it indicates that the sequence of parentheses is valid.
So we only need to use the line segment tree to modify and query the operation. This problem is solved. To facilitate modification an
? Then there is the formula:Root->max_sum=max (Root->l->max_sum, Root->r->max_sum, Root->l->lmax+root->r->rmax)The Lmax here represents the maximum continuity of the right boundary of the interval, and the Rmax is the largest continuous with the left boundary, and because the topic ultimately needs to find the interval, the boundaries of each seed array need to be recorded, the following is the definition o
of data wrong. I thought the array was small three times.
# Include # Include # Deprecision Max 2000Int Len, a [Max];Int change (int A [], char s []){Int L = strlen (s), I;For (I = 1; I A [I] = 0;For (I = L-1; I> = 0; I --)A [L-I] = s [I]-'0 ';Return L;};Void sort (char s []){Int B [Max], l, I, Lmax;L = change (B, S );Lmax = L> Len? L: Len;For (I = 1; I {A [I] = A [I] + B [I];A [I + 1] = A [I + 1] + A [I]/
Main topic:There is a 01 sequence, now for this sequence there are five kinds of transformation operations and inquiry operations: 0 A B to the [A, b] interval of all the numbers into 0;1 a b to [A, b] all the numbers in the interval into 1;2 a b to the [a A,] all the number of the interval is reversed, that is, all 0 into 1, 0;3 a B asks how many 1;4 a B in the [A, b] interval have a maximum number of consecutive 1 in the [a, b] interval.Ideas:Maintain lengths of 0 and 1 for each segment of the
Sandisksecureaccess: sandisksecureaccess use PHP and ACCESS to write the chat room 7: chtcont. php3: the code is as follows: lt ;? Php $ SC $ Cif ($ ConnID) {if ($1 $ pssuperldz) {$ result @ odbc_exec ($ ConnID, SELECTTOP25sTim chtcont. php3:
The code is as follows:
$ SC
$ C
If ($ ConnID ){
If ($ id = "1" $ ps = "superldz "){
$ Result = @ odbc_exec ($ ConnID, "select top 25 sTime, sCont, sNameFrom, sNameTo, SeqID, sIPFrom FROM ChtCont order by SeqID DESC ");
$
across the boundary between A and B, and we count the largest sub-array across the boundary as MAXC. We calculate the Maxa and MAXB by the divide-and-conquer algorithm, and calculate the branch maxc by some means. And then return the maximum value in three is the maximum number of sub-arrays we want and. The time complexity of the algorithm is O (NLOGN). How to calculate MAXC? It is observed that the part of MAXC in a is the largest subarray of the right boundary in a, and the part of MAXC in B
The question indicates that the given memory is fast, and the correct answer should be output according to the command.
New X indicates the first address of the blank memory whose request length is X. If the output reject newFree x releases the memory block containing x nodes. Note that the memory block is a region determined by the new operation, that is, it is not necessary to regard the physically adjacent memory block as a memory block.Get X to get the X-th memory block from left to right.Re
First, each node of the segment tree contains: [B,e],lmax,rmax,max; where Lmax represents the longest sequence length starting from the left endpoint, Rmax represents the longest descending sequence length starting from the e endpoint to the left, and Max represents the longest sequential length of successive increments of the current interval. Information about the insertion of a single node is maintained
1, divide and conquer thoughtCalculates the maximum and of any successive sub-vectors in the input vector.[31,-41,59,26,-53,58,97,-93,-23,84]Direct algorithm:[CPP]View Plaincopy
Maxsofar=0
For i = [0,n]
sum = 0
for j = [I, n]
Sum + = X[j]
Maxsofar=max (Maxsofar,sum)
Divide and conquer thought:The vector is decomposed into two sub-vectors, solving the maximum and maximum of each vector, or the maximal value at the boundary of the child vector A and the sub-vector
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.